#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <list>
#include "../../../NetEngine_Linux/NetEngine_SourceCode/XyRyNet_CommHdr.h"
#include "../../../NetEngine_Linux/NetEngine_SourceCode/XyRyNet_Types.h"
#include "../../../NetEngine_Linux/NetEngine_SourceCode/XyRyNet_ProtocolHdr.h"
#include "../../../NetEngine_Linux/NetEngine_SourceCode/NetEngine_Lib/NetEngine_BaseLib/BaseLib_Define.h"
#include "../../../NetEngine_Linux/NetEngine_SourceCode/NetEngine/NetEngine_Protocol/Protocol_Define.h"
#include "../../../NetEngine_Linux/NetEngine_SourceCode/NetEngine/NetEngine_Protocol/Protocol_Define.h"

//g++ -std=gnu++11 -Wall -g Test_Protocol.cpp -o Test_Protocol -L ../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_BaseLib -L ../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_Core -L ../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_Protocol -lNetEngine_BaseLib -lNetEngine_Core -lNetEngine_Protocol -Wl,-rpath=../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_BaseLib:../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_Core,--disable-new-dtags

BOOL __stdcall XEngine_Protocol_Callback_Trace(LPCTSTR lpszSource, LPCTSTR lpszDestAddr, LPCTSTR lpszRecvAddr, int nTTL, NETENGINE_VALTIME st_VALTime, LPVOID lParam)
{
    printf("Src:%s Dst:%s Rcv:%s TTL:%d Time:%ld.%lu\n", lpszSource, lpszDestAddr, lpszRecvAddr, nTTL, st_VALTime.tv_sec, st_VALTime.tv_usec);
    return TRUE;
}
int Protocol_TestPing()
{
    LPCTSTR lpszSourceAddr = _T("192.168.1.5");
    LPCTSTR lpszDestAddr = _T("129.211.96.206");
    NETENGINE_VALTIME st_VALTime;

    memset(&st_VALTime, '\0', sizeof(NETENGINE_VALTIME));

    if (!Protocol_Icmp_Ping(lpszSourceAddr, lpszDestAddr, &st_VALTime))
    {
        printf("errno\n");
        return 0;
    }

    printf("%ld %lu\n", st_VALTime.tv_sec, st_VALTime.tv_usec);

    return 0;
}
int Protocol_TestTrace()
{
    LPCTSTR lpszSourceAddr = _T("192.168.1.5");
    LPCTSTR lpszDestAddr = _T("129.211.96.206");

    if (!Protocol_Icmp_Traceroute(lpszSourceAddr, lpszDestAddr, XEngine_Protocol_Callback_Trace))
    {
        printf("errno\n");
        return 0;
    }

    return 0;
}
int main()
{
    Protocol_TestPing();
    Protocol_TestTrace();
    return 0;
}
